<!--
*  功能描述：出差申请列表页面
 -->
<template>
  <div>
      <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      prop="StartStaffName"
      label="发起人">
    </el-table-column>
    <el-table-column
      prop="StartRoleName"
      label="发起人职位">
    </el-table-column>
    <el-table-column
      prop="Reason"
      label="出差事由">
    </el-table-column>
    <el-table-column
      prop="BeginTime"
      label="开始时间">
    </el-table-column>
    <el-table-column
      prop="EndTime"
      label="结束时间">
    </el-table-column>
    <el-table-column
      prop="Overtime"
      label="考勤统计">
    </el-table-column>
    <el-table-column
      prop="DrivingNum"
      label="自驾公里数">
    </el-table-column>
    <el-table-column
      prop="RequestRemark"
      label="备注">
    </el-table-column>
    <el-table-column
      prop="CurrentStaffName"
      label="上一操作人">
    </el-table-column>
    <el-table-column
      prop="CurrentRoleName"
      label="上一操作人职位">
    </el-table-column>
    <el-table-column
      prop="InstantiationState"
      label="当前状态">
    </el-table-column>
    <el-table-column label="审批">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handlePass(scope.row)">通过</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleReject(scope.row)">驳回</el-button>
      </template>
    </el-table-column>
  </el-table>
  </div>
</template>

<script>
export default {
    data() {
      return {
        tableData: [],
        requse:"出差",
        UserName:'',
        UserID:'',
        UpRequrestdata:{
            instantiationId:'',
            nodeId:'',
            instantiationState:'',
            startStaffName:'',
            startStaffId:'',
            startRoleName:'',
            startRoleId:'',
            currentStaffName:'',
            currentStaffId:'',
            currentRoleName:'',
            currentRoleId:'',
            nextRoleName:'',
            nextRoleId:'',
            instanCreateTime:'',
            requestInfoId:''
        }
      }
    },
    methods:{
        GetShow(){
            this.$http.get(`Attendance/GetRequestInfos?type=${this.requse}`).then(res=>{
                this.tableData=res.data
            })
        },
        handlePass(row){
            this.UpRequrestdata.instantiationState='通过'
            this.UpRequrestdata.instantiationId=row.InstantiationId
            this.UpRequrestdata.currentStaffName=this.UserName
            this.UpRequrestdata.currentStaffId=this.UserID
            this.UpRequrestdata.startStaffName=row.StartStaffName
            this.UpRequrestdata.startStaffId=row.StartStaffId
            this.UpRequrestdata.startRoleName=row.StartRoleName
            this.UpRequrestdata.startRoleId=row.StartRoleId
            this.UpRequrestdata.requestInfoId=row.RequestInfoId
            this.$http.post(`Attendance/Approval`,this.UpRequrestdata).then(res=>{
                if(res.data>0){
                    alert('通过成功')
                    this.GetShow();
                }
            })
        },
        handleReject(row){
            this.UpRequrestdata.instantiationState='驳回'
            this.UpRequrestdata.instantiationId=row.InstantiationId
            this.UpRequrestdata.startStaffName=this.UserName
            this.UpRequrestdata.startStaffId=this.UserID
            this.$http.post(`Attendance/Approval`,this.UpRequrestdata).then(res=>{
                if(res.data>0){
                    alert('驳回成功')
                    this.GetShow();
                }
            })
        }
    },
    created(){
        this.GetShow();
        this.UserID = sessionStorage.getItem("UserID");
        this.UserName = sessionStorage.getItem("UserName");
    }
}
</script>

<style>

</style>